<?php
define('EZSITETPL_SOAP', 1);

include_once('config.php');

include_once('init.php');

if (!isset($_GET['id']) || !isset($_GET['uid'])) {
    exit(0);
}

$tplid = trim($_GET['id']);
if (!is_numeric($tplid)) {
    exit(0);
}
$ezsite_uid = trim($_GET['uid']);
if (strlen($ezsite_uid) <= 0) {
    exit(0);
}

$tplinfo = unserialize(getTplInfo($ezsite_uid, $tplid));
if (!$tplinfo) {
    mysqli_close($db);
    exit(0);
}

mysqli_close($db);

if (!file_exists(P_TPL.DS.$tplinfo['archive'])) {
    //exit(0);
	$tplinfo['archive'] = substr($tplinfo['archive'],0,-4).'_2.zip';
	if (!file_exists(P_TPL.DS.$tplinfo['archive'])) {
		exit(0);
	}
}
output_file(P_TPL.DS.$tplinfo['archive'], $tplinfo['archive']);

file_put_contents('viewtpl111.txt', P_TPL.DS.$tplinfo['archive']."\r\n\r\n",FILE_APPEND);